package com.duleme.servlet;

import com.duleme.common.EncodeUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "UserInfoServlet",urlPatterns = "/UserInfo")
public class UserInfoServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        EncodeUtils.setEncoding(request,response);
        PrintWriter writer = response.getWriter();
        writer.print(1);
        writer.close();

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int[] nums = {1,2,5,6,8,1,2};
        request.setAttribute("nums",nums);
        System.out.println("set attribute");
        request.getRequestDispatcher("test2.jsp").forward(request,response);
    }
}
